<%@page import="org.pork.domain.EmployeesVO"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<c:if test="${!ajaxRequest}">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="<c:url value="/resources/regist.css"/>" rel="stylesheet"  type="text/css" />	
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body>
</c:if>
	<div id="formsContent">
		<h2>회원가입</h2>
		
		<form:form id="form" method="post" modelAttribute="EmployeesVO" cssClass="cleanform">
		
			<div class="header">
				<c:if test="${not empty message }">
					<div id="message" class="success">${message}</div>
				</c:if>	
				<s:bind path="*">
					<c:if test="${status.error }">
						<div id="message" class="error">잘못 입력하셨습니다</div>
					</c:if>	
				</s:bind>
			</div>
			
			<fieldset>
		  		<legend>Personal Info</legend>
		  		<form:label path="epid">
		  			사원번호 
		 		</form:label>
		  		<form:input path="epid" /><form:errors path="epid" cssClass="error" />
				
		  		<form:label path="pw">
		  			비밀번호 
		 		</form:label>
		  		<form:input path="pw" /><form:errors path="pw" cssClass="error" />
		  	
				<form:label path="name">
		  			이름
		 		</form:label>
		  		<form:input path="name" /><form:errors path="name" cssClass="error" />
		  		
		  		<form:label path="jumin">
		  			주민번호 
		 		</form:label>
		  		<form:input path="jumin" /><form:errors path="jumin" cssClass="error" />
		  		
		  		<form:label path="email">
		  			이메일 
		 		</form:label>
		  		<form:input path="email" /><form:errors path="email" cssClass="error" />
		  	
		  		<form:label path="departCode">
		  			부서코드 
		 		</form:label>
		  		<form:input path="departCode" /><form:errors path="departCode" cssClass="error" />
				
				<form:label path="homeNum">
		  			집전화 
		 		</form:label>
		  		<form:input path="homeNum" /><form:errors path="homeNum" cssClass="error" />
		  		
		  		<form:label path="mobileNum">
		  			휴대폰 
		 		</form:label>
		  		<form:input path="mobileNum" /><form:errors path="mobileNum" cssClass="error" />
		  		
		  		
		  		<form:label path="officeNum">
		  			사무실번호 
		 		</form:label>
		  		<form:input path="officeNum" /><form:errors path="officeNum" cssClass="error" />
		  		
		  		
		  		<form:label path="addr1">
		  			주소 
		 		</form:label>
		  		<form:input path="addr1" /><form:errors path="addr1" cssClass="error" />
		  		
		  		
		  		<form:label path="addr2">
		  			상세주소
		 		</form:label>
		  		<form:input path="addr2" /><form:errors path="addr2" cssClass="error" />
		  		
		  		<form:label path="zipCode">
		  			우편주소 
		 		</form:label>
		  		<form:input path="zipCode" /><form:errors path="zipCode" cssClass="error" />
		  		
		  		<form:label path="startJob">
		  			입사일 
		 		</form:label>
		  		<form:input path="startJob" /><form:errors path="startJob" cssClass="error" />
		  		
		  		<form:label path="gradeLev">
					직급
				</form:label>  
				
		  		<form:select path="gradeLev">
					<form:option value="0">인턴</form:option>
					<form:option value="1">사원</form:option>
					<form:option value="2">주임</form:option>
					<form:option value="3">대리</form:option>
					<form:option value="4">과장</form:option>
					<form:option value="5">차장</form:option>
					<form:option value="6">부장</form:option>
					<form:option value="7">이사</form:option>
					<form:option value="8">상무이사</form:option>
					<form:option value="9">전무이사</form:option>
					<form:option value="10">대표이사</form:option>
				</form:select>  		
			</fieldset>
			<p><button type="submit">Submit</button></p>								
		</form:form>
	
		<script type="text/javascript">
			$(document).ready(function() {
				
 				$("#form").submit(function() {  
					
					console.log($(this).attr("action"));
					
					$.post($(this).attr("action"), $(this).serialize(), function(html) {
						
						console.log(html);
						
						$('#formsContent').replaceWith(html);
						//$('html, body').animate({ scrollTop: $("#message").offset().top }, 500);
					});
					return false;  
				});	 
			});
		</script>	
	</div>	
<c:if test="${!ajaxRequest}">	
</body>
</html>
</c:if>